set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

if(NOT PPLNN_TOOLCHAIN_DIR)
    set(PPLNN_TOOLCHAIN_DIR "/usr")
    if(NOT EXISTS ${PPLNN_TOOLCHAIN_DIR})
        message(FATAL_ERROR "`PPLNN_TOOLCHAIN_DIR` not set.")
    endif()
elseif(NOT EXISTS ${PPLNN_TOOLCHAIN_DIR})
    message(FATAL_ERROR "`PPLNN_TOOLCHAIN_DIR`(${PPLNN_TOOLCHAIN_DIR}) not found")
endif()

set(CMAKE_C_COMPILER   ${PPLNN_TOOLCHAIN_DIR}/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${PPLNN_TOOLCHAIN_DIR}/bin/arm-linux-gnueabihf-g++)
set(CMAKE_C_FLAGS      "${CMAKE_C_FLAGS}  -march=armv7-a -mfpu=neon -static-libgcc -Wno-psabi")
set(CMAKE_CXX_FLAGS    "${CMAKE_CXX_FLAG} -march=armv7-a -mfpu=neon -static-libgcc -static-libstdc++ -Wno-psabi")
if(PPLNN_USE_OPENMP)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
add_link_options("-static")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)